#ifndef HOLDANDSKIP_H
#define HOLDANDSKIP_H

#include <QWidget>
#include <QTimer>

namespace Hydra_HoldAndSkip {

typedef enum _hold_and_skip
{
    NONE,
    HOLD,
    SKIP
}HOLD_SKIP_STATUS;
}

using namespace Hydra_HoldAndSkip;

class HoldAndSkip : public QWidget
{
    Q_OBJECT

public:
    HoldAndSkip(QWidget *parent = 0);

    void setInterval(quint16 interval);
    void setStatus(HOLD_SKIP_STATUS state);

public slots:
    void refresh();

protected:
    void paintEvent(QPaintEvent *event);
    void resizeEvent(QResizeEvent *e);
    void initParam();
    void drawHoldImage(QPainter *pPainter);
    void drawSkipImage(QPainter *pPainter);



private:
    QTimer mTimer;
    quint16 mInterval = 100;
    HOLD_SKIP_STATUS mState = HOLD_SKIP_STATUS::NONE;
    QPoint mCenter;
    quint8 mHoldImageHeightProportion = 80;                                                 // 扣车图形高度占控件高度百分比
    quint8 mHoldImageWidthHeightProportion = 80;                                            // 扣车图形宽度与高度的比例
    quint8 mSkipImageHeightProportion = 60;                                                 // 跳停图形高度占控件高度百分比
    quint8 mSkipImageWidthHeigthProportion = 160;                                           // 跳停图形宽度与高度的比例
    quint8 mSkipImagePlatformLengthProportion = 60;                                         // 跳停图形站台长度占图形宽度的百分比
    quint8 mSkipImagePlatformHeightLengthProportion = 30;                                   // 跳停站台高度和长度比例
    QColor mHoldColor = QColor(189, 0, 0);
    QColor mSkipColor = QColor(255, 242, 0);
    QColor mBaseColor = QColor(212, 212, 212);
    QPoint mTop;
    QPoint mLeft;
    QPoint mRight;
    QPoint mHoldTopLeft;
    QPoint mHoldBottomRight;
    quint8 mLineWidthProportion = 3;                                                        // 禁止X标志线条宽度占控件宽度的百分比
    QRect mInhitRect;                                                                       // 禁止X标志外接矩形
    QRect mSkipPlatformRect;                                                                // 跳停图标站台矩形
    quint8 mArcLineWidthProportion = 6;                                                     // 跳停图标线条宽度占控件宽度的百分比
    QPoint mStart;                                                                          // 箭头三角形顶点
    quint16 mOffset;                                                                        // 因为线宽问题，顶点需要向前偏移
    QPoint mEnd;                                                                            // 终点
    QPoint mTriangleLeft;
    QPoint mTriangleRight;
    QPoint mTriangleMid;                                                                    // 箭头与箭身交汇点(三角形偏移后)
    QRect mArcRect;                                                                         // 圆弧外切矩形
};

#endif // HOLDANDSKIP_H
